<?php
$name = $_POST['name'];
$pwd= $_POST['pwd'];

// 连接数据库
$conn = mysqli_connect('localhost', 'root', 'root', '02');

// 设置编码
mysqli_query($conn, "set charset 'utf8'");
mysqli_query($conn, "set character set 'utf8'");

// sql语句
$sql = "select * from user where name='$name' and pwd='$pwd'";

$res= mysqli_query($conn, $sql);

$count=mysqli_num_rows($res);

if($count>0){
	echo json_encode(array(
	 "code"=>200,
	 "body" => array(
	   "msg"=>"登录成功"
	 )
	));
}else{
	echo json_encode(array(
	"code"=>204,
	"body"=>array(
	 "msg"=>"用户名或密码错误"
	)
	));
}

?>